/**
 * @author CH_ywx
 * @Date 2023-05-28
 * @Description
 */
package io.xccit.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *@author CH_ywx
 *@Date 2023-05-28
 *@Description MyBatisPlus配置文件
 */
@Configuration //配置类加配置注解
@MapperScan("io.xccit.mapper")
public class MyBatisConfig {
    @Bean //返回的是一个bean,需要被Spring识别
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); //加入一个内部插件--->PaginationInnerInterceptor:内部分页插件
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); //乐观锁内部插件
        return interceptor;
    }
}
